package com.lib.common.widget.config

import android.content.Context
import android.view.LayoutInflater
import com.lib.common.R
import com.scwang.smartrefresh.layout.SmartRefreshLayout
import com.scwang.smartrefresh.layout.api.RefreshFooter
import com.scwang.smartrefresh.layout.api.RefreshHeader


/**
 * Copyright (C), 2020-2020, 享物说
 * FileName: SmartRefreshLayoutConfigHelper
 * Author: keanbin
 * Date: 2020-02-08 10:10
 * Description: SmartRefreshLayout 配置辅助类
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
class SmartRefreshLayoutConfigHelper {

    companion object {

        /**
         * 全局配置
         */
        fun globalConfig(context: Context) {
            //设置全局的Header构建器
            SmartRefreshLayout.setDefaultRefreshHeaderCreator { context, layout ->
//                layout.setPrimaryColorsId(R.color.colorPrimary, android.R.color.white)//全局设置主题颜色
//                ClassicsHeader(context)//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header，默认是 贝塞尔雷达Header

                LayoutInflater.from(context).inflate(R.layout.refresh_header, null) as RefreshHeader
            }

            //设置全局的Footer构建器
            SmartRefreshLayout.setDefaultRefreshFooterCreator { context, layout ->
                //指定为经典Footer，默认是 BallPulseFooter
//                ClassicsFooter(context).setDrawableSize(20f)
                LayoutInflater.from(context).inflate(R.layout.refresh_footer, null) as RefreshFooter
            }
        }

    }
}